package org.sokolenko.regexp;

import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.editor.Editor;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * @author Anatoliy Sokolenko
 *         1 Aug 2009 0:50:05
 */
public class EvaluationProjectComponent implements ProjectComponent {
    private Project project;
    private EvaluationForm form;

    public EvaluationProjectComponent( Project project ) {
        this.project = project;
        form = new EvaluationForm( project );
    }

    public void initComponent() {
        // TODO: insert component initialization logic here
    }

    public void disposeComponent() {
        // TODO: insert component disposal logic here
    }

    @NotNull
    public String getComponentName() {
        return "EvaluationProjectComponent";
    }

    public void projectOpened() {
        // called when project is opened
    }

    public void projectClosed() {
        // called when project is being closed
    }

    public void showEvaluationForm( String expression, Editor editor ) {
        EvaluationData data = new EvaluationData( expression );
        form.setData( data );
        form.show(editor);
    }
}
